package servlet;

import server.HttpProtocoUtil;
import server.HttpServlet;
import server.Request;
import server.Response;

import java.io.IOException;

/**
 * @author songyi
 * @date 2020/6/28 0028 16:36
 * @description
 */
public class MyServlet extends HttpServlet {
    @Override
    public void doGet(Request request, Response response) {
        String content = "<h1>Demo2 MyServlet Get</h1>";
        try {
            response.output(HttpProtocoUtil.getHeader200(content.getBytes().length) + content);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void doPost(Request request, Response response) {
        String content = "<h1>Demo2 MyServlet Post</h1>";
        try {
            response.output(HttpProtocoUtil.getHeader200(content.getBytes().length) + content);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void init() throws Exception {

    }

    @Override
    public void destory() throws Exception {

    }
}
